In [4]:
import pandas as pd
import plotly.io as pio
pio.renderers.default='notebook'

# Read the CSV file into a pandas DataFrame
df = pd.read_csv('Biomass_History.csv')
df["mean_by_year"] = df.iloc[:, 3:].mean(axis=1)
df["variance_by_year"] = df.iloc[:, 3:].var(axis=1)
In [5]:
long_df = pd.melt(
    df,
    id_vars=["Index", "Latitude", "Longitude"],
    value_vars=["2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017","mean_by_year","variance_by_year"],
    var_name="Year",
    value_name="Value"
)

print(long_df)
       Index  Latitude  Longitude              Year      Value
0          0  24.66818   71.33144              2010   8.475744
1          1  24.66818   71.41106              2010  24.029778
2          2  24.66818   71.49069              2010  44.831635
3          3  24.66818   71.57031              2010  59.974419
4          4  24.66818   71.64994              2010  14.653370
...      ...       ...        ...               ...        ...
24175   2413  20.15456   72.84432  variance_by_year   1.034014
24176   2414  20.15456   72.92394  variance_by_year   0.000140
24177   2415  20.15456   73.00357  variance_by_year   0.000015
24178   2416  20.15456   73.08319  variance_by_year   0.268278
24179   2417  20.15456   73.16282  variance_by_year   0.019717

[24180 rows x 5 columns]
In [6]:
import plotly.express as px

fig = px.scatter(long_df, x="Longitude", y="Latitude", animation_frame="Year", 
           color="Value", hover_name="Index",color_continuous_scale="jet")

fig["layout"].pop("updatemenus") 
fig.update_layout(width=20 * 32, height=10 * 64)  

fig.show()
In [ ]: